package com.yc.study.config.file;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

import java.util.UUID;

/**
 * @author liupeng
 */
public class FileUploadConfig {
  private static final String PATH = "/Users/liupeng/";
  private static final String MAPPING_PATH = "/download2/";

  public static PathInfo generatePath(MultipartFile file) {
    String filename = file.getOriginalFilename();
    filename = UUID.randomUUID().toString() + filename;
    return new PathInfo(PATH + filename, MAPPING_PATH + filename);
  }
  public static PathInfo getPathInfo(String filename){
    return new PathInfo(PATH + filename, MAPPING_PATH + filename);
  }

  @Data
  @AllArgsConstructor
  public static class PathInfo {
    /** 真实磁盘上的路径 */
    private String realPath;
    /** tomcat映射路径 */
    private String MappingPath;
  }
}
